{%- extends "basic/layout.html" %}

{# Do this so that bootstrap is included before the main css file #}
{%- block htmltitle %}
  {% set script_files = script_files + ["_static/myscript.js"] %}
  <!-- Licensed under the Apache 2.0 License -->
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/fonts/open-sans/stylesheet.css', 1) }}" />
  <!-- Licensed under the SIL Open Font License -->
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/fonts/source-serif-pro/source-serif-pro.css', 1) }}" />
  <link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/bootstrap.min.css', 1) }}" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  {{ super() }}
{%- endblock %}

{%- block extrahead %}
  {% if theme_touch_icon %}
  <link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
  {% endif %}
  {{ super() }}
{% endblock %}

{# Displays the URL for the homepage if it's set or the master_doc if it is not #}
{% macro homepage() -%}
  {%- if theme_homepage %}
    {%- if hasdoc(theme_homepage) %}
      {{ pathto(theme_homepage) }}
    {%- else %}
      {{ theme_homepage }}
    {%- endif %}
  {%- else %}
    {{ pathto(master_doc) }}
  {%- endif %}
{%- endmacro %}

{# Displays the URL for the tospage if it's set or falls back to homepage macro #}
{% macro tospage() -%}
  {%- if theme_tospage %}
    {%- if hasdoc(theme_tospage) %}
      {{ pathto(theme_tospage) }}
    {%- else %}
      {{ theme_tospage }}
    {%- endif %}
  {%- else %}
    {{ homepage() }}
  {%- endif %}
{%- endmacro %}

{# Displays the URL for the projectpage if it's set or falls back to homepage macro #}
{% macro projectlink() -%}
  {%- if theme_projectlink %}
    {%- if hasdoc(theme_projectlink) %}
      {{ pathto(theme_projectlink) }}
    {%- else %}
      {{ theme_projectlink }}
    {%- endif %}
  {%- else %}
    {{ homepage() }}
  {%- endif %}
{%- endmacro %}

{# Displays the next and previous links both before and after content #}
{% macro render_relations() -%}
  {% if prev or next %}
  <div class="footer-relations">
    {% if prev %}
      <div class="float-left">
        <a class="btn btn-outline btn-sm" href="{{ prev.link|e }}" title="{{ _('previous chapter')}} (use the left arrow)">← {{ prev.title }}</a>
      </div>
    {% endif %}
    {%- if next and next.title != '&lt;no title&gt;' %}
      <div class="float-right">
        <a class="btn btn-outline btn-sm" href="{{ next.link|e }}" title="{{ _('next chapter')}} (use the right arrow)">{{ next.title }} →</a>
      </div>
    {%- endif %}
    </div>
    <div class="clearer"></div>
  {% endif %}
{%- endmacro %}

{%- macro guzzle_sidebar() %}
  <div id="left-column">
    <div class="sphinxsidebar">
      {%- if sidebars != None %}
        {#- new style sidebar: explicitly include/exclude templates #}
        {%- for sidebartemplate in sidebars %}
        {%- include sidebartemplate %}
        {%- endfor %}
      {% else %}
        {% include "logo-text.html" %}
        {% include "globaltoc.html" %}
        {% include "searchbox.html" %}
      {%- endif %}
    </div>
  </div>
{%- endmacro %}

{%- block content %}

  {%- if pagename == 'index' and theme_index_template %}
    {% include theme_index_template %}
  {%- else %}
    <div class="container-wrapper">

      <div id="mobile-toggle">
        <a href="#"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></a>
      </div>

      {%- block sidebar1 %}{{ guzzle_sidebar() }}{% endblock %}

      {%- block document_wrapper %}
        {%- block document %}
        <div id="right-column">
          {% block breadcrumbs %}
          <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
              <li class="breadcrumb-item"><a href="{{ pathto(master_doc) }}">Docs</a></li>
              {% for doc in parents %}
              <li class="breadcrumb-item"><a href="{{ doc.link|e }}">{{ doc.title }}</a></li>
              {% endfor %}
              <li class="breadcrumb-item">{{ title }}</li>
            </ol>
          </nav>
          {% endblock %}
          <div class="document clearer body">
            {% block body %} {% endblock %}
          </div>
          {%- block bottom_rel_links %}
            {{ render_relations() }}
          {%- endblock %}
        </div>
        <div class="clearfix"></div>
        {%- endblock %}
      {%- endblock %}

      {%- block comments -%}
        {% if theme_disqus_comments_shortname %}
        <div class="container comment-container">
          {% include "comments.html" %}
        </div>
        {% endif %}
      {%- endblock %}
    </div>
  {%- endif %}
  {%- endblock %}

{%- block footer %}
<script type="text/javascript">
  $("#mobile-toggle a").click(function () {
    $("#left-column").toggle();
  });
</script>
<script type="text/javascript" src="{{ pathto('_static/js/bootstrap.js', 1)}}"></script>
{%- block footer_wrapper %}
  <div class="footer">
    &copy; Copyright {{ copyright }}. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
  </div>
{%- endblock %}
{%- block ga %}
  {%- if theme_google_analytics_account %}
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', '{{ theme_google_analytics_account }}']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
  {%- endif %}
{%- endblock %}
{%- endblock %}
